package com.example.paopao.consumer.worker.config;

import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.validation.Validation;
import javax.validation.Validator;

@Slf4j
@Configuration
public class ValidationConfiguration {

    @Bean
    public Validator validation(){
        return  Validation.byProvider(HibernateValidator.class)
                .configure()    //开始配置
                .failFast(true) //配置快速失败
                .buildValidatorFactory() //构建validator工厂
                .getValidator(); //从validator工厂中validator对象
    }
}
